package com.katze.boot.system.domain;

import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.katze.boot.common.converter.DateTimeStringConverter;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

@Data
@TableName("sys_log")
@ExcelIgnoreUnannotated
public class SysLog implements Serializable {

    @Serial
    private static final long serialVersionUID = -8878596941954995444L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ExcelProperty(value = "操作人ID")
    private Long userId;

    @ExcelProperty(value = "操作人")
    private String username;

    @ExcelProperty(value = "操作描述")
    private String operation;

    @ExcelProperty(value = "耗时（毫秒）")
    private Long time;

    @ExcelProperty(value = "执行方法")
    private String method;

    @ExcelProperty(value = "方法参数")
    private String params;

    @ExcelProperty(value = "IP地址")
    private String ip;

    @ExcelProperty(value = "操作时间", converter = DateTimeStringConverter.class)
    private Date createTime;

    // 起始/结束时间调整成时间范围（timeFrame），前端以‘,’拼接开始&结束时间，可以删除createTimeFrom&createTimeTo
    @Deprecated
    private transient String createTimeFrom;
    @Deprecated
    private transient String createTimeTo;
    private transient String timeFrame;

    // 通过登录记录关联
    @Deprecated
    @ExcelProperty(value = "操作地点")
    private String location;

    public SysLog() {}

    public SysLog(String ip, long time){
        this.ip = ip;
        this.time = time;
    }
}
